﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using _4T.DAL;
using _4T.Data;

namespace _4T.BLL
{
    public class PersonalInfoBLL
    {
        private PersonalInfoDAL m_PersonDAL;
        protected PersonalInfoDAL PersonDAL
        {
            get
            {
                if (m_PersonDAL == null)
                {
                    m_PersonDAL = new PersonalInfoDAL();
                }

                return m_PersonDAL;
            }
        }

        public PersonalInfoBLL() { }

        public PersonalInfo ValidatePerson(string username, string password)
        {
            return PersonDAL.GetPersonalInfo(username, password);
        }

        public List<PersonalInfo> GetPersonalListInRole(int role)
        {
            return PersonDAL.GetPersonalListInRole(role);
        }

        public List<PersonalInfo> GetPersonalListInSpecificRole(int role)
        {
            return PersonDAL.GetPersonalListInSpecificRole(role);
        }

        public int Register(string username, string password, string fullName, string phoneNumber,
            string email, string addr, string description)
        {
            return PersonDAL.InsertPersonalInfo(username, username, password, fullName, phoneNumber, email, addr, description, "user", 0, "0");
        }

        public PersonalInfo GetPersonalInfo(string personalCode)
        {
            return PersonDAL.GetPersonalInfo(personalCode);
        }

        public int UpdatePersonalInfo(string personalCode, string username, string password, string fullName,
            string phoneNumber, string email, string addr, string desc, int role, string rights)
        {
            return PersonDAL.UpdatePersonalInfo(personalCode, username, password, fullName, phoneNumber, email,
                addr, desc, role, rights);
        }

        public IEnumerable<PersonalInfo> GetAllPersonalInfo()
        {
            return new PersonalInfoDAL().GetAllPersonalInfo();
        }

        public IEnumerable<ProfileVerifierCus> GetAllProfileByVerifier(string verifier)
        {
            return new PersonalInfoDAL().GetAllProfileByVerifier(verifier);
        }
    }
}